<template>
  <el-card class="box-card el-card-flex outer-style">
    <div slot="header" class="clearfix">
      <span>{{headLine}}</span>
    </div>
    <div class="text item el-over-auto el-card-flex">
      <el-form :model='formData' :inline="true" ref='formData' label-width="140px">
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织基本信息
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-input class='visible-input' v-model="formData.orgId"></el-input>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="组织名称:" v-if="headLine=='新增'">
              <el-input placeholder="请输入/选择组织名称" v-model="formData.name" class='input-width'>
                <el-button slot="append" icon="el-icon-search" @click='selectArchivesName'></el-button>
              </el-input>
            </el-form-item>
            <el-form-item label="组织名称:" v-else class='inner-inputs-style'>
              <el-input readonly v-model="formData.name">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-input class='visible-input' v-model="formData.treeId"></el-input>
            <el-input class='visible-input' v-model="formData.parentOrgId"></el-input>
            <el-form-item class='inner-inputs-style' label="隶属机构:" prop="orgName" v-if="headLine=='新增'">
              <el-input class='input-width' readonly placeholder="请输入/选择隶属机构" v-model="formData.orgName">
                <el-button slot="append" icon="el-icon-search" @click='selectOrgnizationName'></el-button>
              </el-input>
              <!-- <el-input placeholder="请输入隶属机构" v-model="formData.orgName"></el-input> -->
            </el-form-item>
            <el-form-item class='inner-inputs-style' label="隶属机构" v-else>
              <el-input readonly v-model="formData.orgName">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="组织等级:" prop="orgDegree" :rules="{required: true, message: '请选择组织组织等级'}">
              <el-select class='input-width' placeholder="请选择组织等级" v-model="formData.orgDegree">
                <el-option v-for="item in orgTypeDegree" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span='24'>
            <el-form-item label="组织分类:" prop="orgType" :rules="{required: true, message: '请选择组织分类'}">
              <el-radio-group v-model="formData.orgType">
                <el-radio :label="item.id" v-for="item in orgTypeData" :key='item.id'>{{item.name}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="排序号:">
              <el-input placeholder="请输入排序号" v-model="formData.sortNo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="ERP单位编码:">
              <el-input placeholder="请输入ERP单位编码" v-model="formData.erpOrgCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span='8' class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="ERP单位名称:">
              <el-input placeholder="请输入ERP单位名称" v-model="formData.erpOrgName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="组织档案编码:">
              <el-input placeholder="自动生成组织档案编码" v-model="formData.orgCode" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="组织注册ID:">
              <el-input placeholder="请填写组织注册ID" v-model="formData.id"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="简称:">
              <el-input placeholder="请填写简称" v-model="formData.alias"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="曾用名:">
              <el-input placeholder="请输入曾用名" v-model="formData.historyNames"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="英文名:">
              <el-input placeholder="请填写英文名" v-model="formData.property3"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col class='textarea-inner-style'>
            <el-form-item label="备注:" class='inner-inputs-style'>
              <el-input type="textarea" :rows="3" placeholder="请填写备注" v-model="formData.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织注册信息
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="社会统一信用代码:">
              <el-input placeholder="请输入社会统一信用代码" v-model="formData.creditCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="组织机构代码:">
              <el-input placeholder="请填写组织机构代码" v-model="formData.orgNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="纳税人识别号:">
              <el-input placeholder="请输入纳税人识别号" v-model="formData.taxNumber"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="企业状态:" prop="regStatus" :rules="{required: true, message: '请填选择企业状态'}">
              <el-select class='input-width' placeholder="企业状态" v-model="formData.regStatus">
                <el-option v-for="item in companyStatus" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注册号:">
              <el-input placeholder="请输入注册号" v-model="formData.regNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注册资本:">
              <el-input placeholder="请填写注册资本" v-model="formData.regCapital"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注册资本币种:">
              <el-input placeholder="请输入注册资本币种" v-model="formData.regcapitalCurrency"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="公司类型:">
              <el-select class='input-width' placeholder="公司类型" v-model="formData.companyOrgType">
                <el-option v-for="item in companyType" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="实收注册资金:">
              <el-input placeholder="请输入实收注册资金" v-model="formData.actualCapital"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="实收注册资本币种:">
              <el-input placeholder="请输入实收注册资本币种" v-model="formData.actualCapitalCurrency"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="登记机关:">
              <el-input placeholder="请填写登记机关" v-model="formData.regInstitute"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="国别或地区:">
              <el-select class='input-width' placeholder="请选择国别或地区" v-model="formData.zone">
                <el-option v-for="item in zoneData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="省份简称:">
              <el-input placeholder="请输入省份简称" v-model="formData.base"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注册地址:">
              <el-input placeholder="请填写注册地址" v-model="formData.regLocation"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>组织简介
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="企业标签:">
              <el-input placeholder="请输入企业标签" v-model="formData.tags"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="企业评分:">
              <el-input placeholder="请输入企业评分" v-model="formData.percentileScore"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="小微企业:">
              <el-radio-group v-model="formData.isMicroEnt">
                <el-radio :label="0">是</el-radio>
                <el-radio :label="1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="法人类型:">
              <el-radio-group v-model="formData.type">
                <el-radio :label="1">自然人</el-radio>
                <el-radio :label="2">公司</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="法人:">
              <el-input placeholder="请输入法人" v-model="formData.legalPersonName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="法人身份证:">
              <el-input placeholder="请输入法人身份证" v-model="formData.legalPersonId"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="人员规模:">
              <el-input placeholder="请输入人员规模" v-model="formData.staffNumRange"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="参保人数:">
              <el-input placeholder="请输入参保人数" v-model="formData.socialStaffNum"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="行业:">
              <el-input placeholder="请输入行业" v-model="formData.industry"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="股票类型:">
              <el-select class='input-width' placeholder="股票类型" v-model="formData.bondType">
                <el-option v-for="item in bondTypeDatas" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="股票号:">
              <el-input placeholder="请输入股票号" v-model="formData.bondNum"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="股票名:">
              <el-input placeholder="请填写股票名" v-model="formData.bondName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="股票曾用名:">
              <el-input placeholder="请填写股票曾用名" v-model="formData.usedBondName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="成立日期:">
              <el-date-picker class='input-width' v-model="formData.estiblishTime" type="date" placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日" value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="核准时间:">
              <el-date-picker class='input-width' v-model="formData.approvedTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="经营开始时间:">
              <el-date-picker class='input-width' v-model="formData.fromTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="经营结束时间:">
              <el-date-picker class='input-width' v-model="formData.toTime" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="吊销日期:">
              <el-date-picker class='input-width' v-model="formData.revokeDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="吊销原因:">
              <el-input placeholder="请填写吊销原因" v-model="formData.revokeReason"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注销日期:">
              <el-date-picker class='input-width' v-model="formData.cancelDate" type="date" placeholder="选择日期" format="yyyy 年 MM 月 dd 日"
                value-format="timestamp">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="注销原因:">
              <el-input placeholder="请填写注销原因" v-model="formData.cancelReason"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="登记注册类型:">
              <el-select class='input-width' placeholder="登记注册类型" v-model="formData.orgCat">
                <el-option v-for="item in subOrgReqCatData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="业务板块:">
              <el-select class='input-width' placeholder="业务板块" v-model="formData.bizCat">
                <el-option v-for="item in subOrgPlateData" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="网站网址:">
              <el-input v-model="formData.webUrl" placeholder="请填写网站网址"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col class='textarea-inner-style'>
            <el-form-item label="经营范围:" class='inner-inputs-style'>
              <el-input type="textarea" :rows="3" placeholder="请填写经营范围" v-model="formData.businessScope"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider class='divider-code'></el-divider>
        <el-row class='code-first-row'>
          <span class='basic-info'>
            <div class='line-style'></div>联系方式
          </span>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="邮编:">
              <el-input v-model="formData.zipCode" placeholder="请输入邮编"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="电子邮箱:">
              <el-input v-model="formData.email" placeholder="请输入电子邮箱"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="联系人:">
              <el-input v-model="formData.linkMan" placeholder="请填写联系人"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class='code-first-row'>
          <el-col :span="8" class='textarea-inner-style'>
            <el-form-item class='inner-inputs-style' label="联系电话:">
              <el-input v-model="formData.lintel" placeholder="请填写联系电话"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div style="text-align: right;margin-right: 8px;margin-bottom: 8px;margin-top: 8px;">
      <el-button type="primary" @click="archivesSave('formData')">保存 <i class="el-icon-document-checked"></i>
      </el-button>
      <el-button type="danger" @click="archivesEvt()">关闭 <i class="el-icon-close"></i>
      </el-button>
    </div>
    <!-- 组织名称弹框 -->
    <el-dialog title="组织档案" class="demo-ruleForm" custom-class="el-dialog-flex" :visible.sync="archiveVisible"
      :close-on-click-modal="false" :close-on-press-escape="false">
      <div>
        <el-form @submit.native.prevent>
          <el-form-item>
            <el-input clearable v-model="searchWordArchive" placeholder="请输全称" style="width:280px;"
              @keyup.enter.native="originalSearchArchiveEvent" @clear="clearSearchArchiveEvent">
              <el-button slot="append" icon="el-icon-search" @click="originalSearchArchiveEvent"></el-button>
            </el-input>
          </el-form-item>
        </el-form>
      </div>
      <div style='overflow: auto;'>
        <el-table :data="archiveTableData" border highlight-current-row @current-change="handleSelectionArchive" ref="archiveTableData">
          <el-table-column min-width="50px" align="center" sortable :show-overflow-tooltip="true" label="序号" type="index"></el-table-column>
          <el-table-column min-width="200px" sortable :show-overflow-tooltip="true" property="name" label="全称"></el-table-column>
          <el-table-column min-width="160px" align="center" sortable :show-overflow-tooltip="true" property="creditCode"
            label="社会统一信用代码"></el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <el-pagination background @size-change="handleSizeArchiveChange" :current-page="currentArchivePage"
        @current-change="handleCurrentArchiveChange" :page-size="pageArchiveSize" layout="total, sizes, prev, pager, next, jumper"
        :total="totalArchive"></el-pagination>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleArchiveSure"> 确定<i class="el-icon-document-checked el-icon--right"></i></el-button>
        <el-button type="danger" @click="archiveVisible=false">关闭 <i class="el-icon-close"></i></el-button>
      </span>
    </el-dialog>
    <!-- 隶属机构弹框 -->
    <el-dialog title="隶属机构" :visible.sync="organizationVisible" class="demo-ruleForm" custom-class="el-dialog-flex"
      :close-on-click-modal="false" :close-on-press-escape="false">
      <div>
        <el-form @submit.native.prevent>
          <el-input v-model="orgNameSearch" placeholder="请搜索..." suffix-icon="el-icon-search" clearable></el-input>
          <el-form-item style="margin-top: 10px;">
            <el-tree ref='tree' v-if="!orgNameSearch" :load="loadNode" node-key="id" :props="defaultProps"
              :highlight-current="true" lazy @node-click="handleNodeClick" :current-node-key="currentNodekey"
              :default-expanded-keys="expandedkeys" :key='treeKey'>
            </el-tree>
            <el-tree ref='tree' v-if="orgNameSearch" :data="searchTreeData" node-key="id" :props="defaultProps"
              :highlight-current="true" @node-click="handleNodeClick" default-expand-all>
            </el-tree>
          </el-form-item>
        </el-form>
      </div>
      <div style='overflow: auto;'>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleOrganizationSure"> 确定<i class="el-icon-document-checked el-icon--right"></i></el-button>
        <el-button type="danger" @click="organizationVisible=false">关闭 <i class="el-icon-close"></i></el-button>
      </span>
    </el-dialog>
  </el-card>
</template>
<script>
  import {
    Dialog,
    Table,
    TableColumn,
    Pagination,
    MessageBox,
    Message,
    Divider,
    datePicker,
    Tree
  } from 'element-ui'
  import {
    archiveList, //组织档案查询
    archiveSearch, //组织档案搜索
    addOrEdit, //新增编辑组织树中信息
  }
  from '@/api/org/organizationTree/addOrEditorganizationTree'
  import {
    archiveDetails, //企业详情
    childrenTree, //父级组织下的下级组织
    searchTree, //组织树查询
    treeRoot, //组织树根节点
  }
  from '@/api/org/organizationTree/organizationTree.js'
  import {
    comboBoxDataSelect, //下拉通用接口
  } from '@/api/org/orgnizationArchives/orgnizationArchives.js'
  export default {
    name: "addOrEditorganizationTree",
    components: {
      'el-dialog': Dialog, // 对话框
      'el-table': Table, // 表格
      'el-table-column': TableColumn, // 表格列
      'el-pagination': Pagination, // 分页
      'el-divider': Divider, //分割线
      'el-date-picker': datePicker, //日期选择器
      'el-tree': Tree, //树形菜单
    },
    data() {
      return {
        defaultProps: { //组织树默认配置
          label: 'orgName',
          isLeaf: 'isLeaf'
        },
        searchTreeData: [], //树搜索
        currentTopTreeId: '', //当前顶级树Id
        currentNodekey: '',
        expandedkeys: [],
        treeKey: 0,
        orgNameSearch: '', //隶属机构树搜索
        searchWordArchive: '', //组织档案搜索字眼
        selectParentTreeId: '', //选中隶属机构上级树Id
        selectParentOrgName: '', //选中隶属机构上级组织名
        searchWordOrganization: '', //隶属机构搜索字眼
        archiveTableData: [], //组织档案表格
        orgnizationTableData: [], //隶属机构表格
        parentTreeId: '', //上级树treeId
        parentTreeName: '', //上级机构名称
        totalArchive: 0, //组织档数据总条数
        totalOrganization: 0, //组织档数据总条数
        currentArchivePage: 1, //组织档当前页
        currentOrganizationPage: 1, //隶属机构当前页
        pageArchiveSize: 20, //组织档案当前条数
        pageOrganizationSize: 20, //隶属机构当前条数
        archivesSeachStyle: 'N', //组织档案查询判断（Y查询，N未查询）
        organiztionSeachStyle: 'N', //组织档案查询判断（Y查询，N未查询）
        archiveVisible: false, //组织档案弹框
        organizationVisible: false, //隶属机构弹框
        chooseArchive: {}, //组织档案选中数据
        formData: {}, //表单
        headLine: '', //标题
        orgTypeData: [], //组织类型
        companyStatus: [], //企业状态
        companyType: [], //公司类型
        zoneData: [], //国别或地区
        bondTypeDatas: [], //股票类型
        subOrgReqCatData: [], //登记注册类型
        subOrgPlateData: [], //业务板块
        orgTypeDegree: [], //组织等级
        archivesDatas: {}, //档案传参实体
        treeDatas: {}, //树传参实体
      }
    },
    created() {
      this.currentUserId = this.$store.state.userInfo.userId
      let paramsData = this.$route.params.data
      this.parentTreeName = paramsData.parentOrgName
      this.currentTopTreeId = paramsData.topTreeId
      this.headLine = paramsData.title
      if (this.headLine == '编辑') {
        this.getAchiveDetails(paramsData)
      } else {
        this.formData.orgName = paramsData.orgName
        this.formData.parentOrgId = paramsData.treeId
      }
      this.getsubOrgCat()
      this.getCompanyStatus()
      this.getCompanyType()
      this.getZone()
      this.getBondType()
      this.getBondType()
      this.getSubOrgCat()
      this.getSubOrgPlate()
      this.getsubOrgDegree()

    },
    watch: {
      orgNameSearch(val) { //搜索
        let data = {
          name: val,
          userId: this.currentUserId,
          treeId: this.currentTopTreeId
        }
        if (val) {
          searchTree(data).then(res => {
            let datas = res.data.data;
            this.removeTip() //移除默认提示
            this.deepChild(datas);
            this.searchTreeData = datas;
          });
        } else {
          this.treeKey += 1;
        }
      }
    },
    methods: {
      getAchiveDetails(datas) { //获取详情
        archiveDetails(datas.orgId).then(res => {
          if (res.data.code == 10000) {
            this.formData = res.data.data
            this.formData.orgName = datas.parentOrgName
            this.formData.name = res.data.data.name
            this.formData.parentOrgId = datas.parentOrgId
            this.$set(this.formData, 'orgDegree', datas.orgDegree)
            this.$set(this.formData, 'sortNo', datas.sortNo)
            this.$set(this.formData, 'erpOrgCode', datas.erpOrgCode)
            this.$set(this.formData, 'erpOrgName', datas.erpOrgName)
            this.$set(this.formData, 'remark', datas.remark)
            this.$set(this.formData, 'treeId', datas.treeId)
            this.$set(this.formData, 'parentOrgId', datas.parentTreeId)
          }
        })
      },
      getsubOrgCat() { //组织类型
        comboBoxDataSelect('c937124a153a4ad2953b690733175f6f').then(res => {
          if (res.data.code == 10000) {
            this.orgTypeData = res.data.data
          }
        })
      },
      getsubOrgDegree() { //组织等级
        comboBoxDataSelect('dfadeac296ca4077a63eea980a80e351').then(res => {
          if (res.data.code == 10000) {
            this.orgTypeDegree = res.data.data
          }
        })
      },
      getCompanyStatus() { //获取企业状态
        comboBoxDataSelect('3a3e807fb3de4652b6c79572f993b903').then(res => {
          if (res.data.code == 10000) {
            this.companyStatus = res.data.data
          }
        })
      },
      getCompanyType() { //获取公司类型
        comboBoxDataSelect('8bbc223e0a444d049d32485e83c19580').then(res => {
          if (res.data.code == 10000) {
            this.companyType = res.data.data
          }
        })
      },
      getZone() { //获取国别或地区
        comboBoxDataSelect('99c3b662fabc46e28a924134fd4a2f28').then(res => {
          if (res.data.code == 10000) {
            this.zoneData = res.data.data
          }
        })
      },
      getBondType() { //获取股票类型
        comboBoxDataSelect('78b4ad0dd6384f0c9ba55ef30671a72c').then(res => {
          if (res.data.code == 10000) {
            this.bondTypeDatas = res.data.data
          }
        })
      },
      getSubOrgCat() { //获取登记注册类型
        comboBoxDataSelect('84da22743c194f7f9f6d3e9f773a4912').then(res => {
          if (res.data.code == 10000) {
            this.subOrgReqCatData = res.data.data
          }
        })
      },
      getSubOrgPlate() { //获取业务板块
        comboBoxDataSelect('494d92fc6f8c41e48e62f7cc11f1ec67').then(res => {
          if (res.data.code == 10000) {
            this.subOrgPlateData = res.data.data
          }
        })
      },
      pageArchive() { //组织档案页数页码初始化
        this.currentArchivePage = 1
        this.pageArchiveSize = 20
      },
      getArchiveTableData() { //组织档案表格通用方法
        this.archivesSeachStyle = 'N'
        let data = {
          page: this.currentArchivePage,
          size: this.pageArchiveSize
        }
        archiveList(data).then(res => {
          if (res.data.code == 10000) {
            this.archiveTableData = res.data.data.records
            this.totalArchive = res.data.data.total
          }
        })
      },
      pageOrganization() { //组织档案页数页码初始化
        this.currentOrganizationPage = 1
        this.pageOrganizationSize = 20
      },
      getOrginationTableData() { //隶属机构表格通用方法
        this.organiztionSeachStyle = 'N'
        let data = {
          page: this.currentOrganizationPage,
          size: this.pageOrganizationSize
        }
        childrenTree(data).then(res => {
          if (res.data.code == 10000) {
            this.archiveTableData = res.data.data.records
            this.totalArchive = res.data.data.total
          }
        })
      },
      loadNode(node, resolve) { //组织树懒加载
        if (node.level == 0) {
          treeRoot().then(res => {
            if (res.data.code == 10000) {
              let data = res.data.data
              data.forEach(item => {
                item.label = item.orgName
                item.id = item.treeId
                item.isLeaf = item.isLeaf == 'n' ? false : true
              })
              if (data.length > 0) {
                this.currentNodekey = data[0].treeId
                this.expandedkeys.push(data[0].treeId)
                this.$nextTick(() => {
                  this.$refs.tree.setCurrentKey(this.currentNodekey)
                })
              }
              return resolve(data)
            }
          });
        } else {
          childrenTree(node.data.treeId).then(res => {
            if (res.data.code == 10000) {
              let data = res.data.data
              data.forEach(item => {
                item.label = item.orgName
                item.id = item.treeId
                item.isLeaf = item.isLeaf == 'n' ? false : true
              })
              return resolve(data)
            }
          })
        }
      },
      handleNodeClick(val, node) { //树点击
        this.selectParentTreeId = val.treeId
        this.selectParentOrgName = val.orgName
      },
      getOriginalArchiveTableData() { //组织档案表格数据初始化
        this.pageArchive()
        this.getArchiveTableData()
      },
      archivesSearch() { //组织普通查询通用方法
        this.archivesSeachStyle = 'Y'
        let data = {
          page: this.currentArchivePage,
          size: this.pageArchiveSize,
          name: this.searchWordArchive
        }
        if (data.name && data.name != '/' && data.name != '\\' && data.name != '|') {
          archiveSearch(data).then(res => {
            if (res.data.code == 10000) {
              this.archiveTableData = res.data.data.records
              this.totalArchive = res.data.data.total
            }
          })
        }
      },
      selectArchivesName() { //选择组织名称
        this.archiveVisible = true
        this.searchWordArchive = ''
        this.getOriginalArchiveTableData()

      },
      selectOrgnizationName() { //选择隶属机构
        this.organizationVisible = true
      },
      handleSelectionArchive(val, oldval) { //选择组织名称单选
        this.chooseArchive = val
      },
      originalSearchArchiveEvent() { //组织档案搜索
        this.pageArchive()
        this.archivesSearch()
      },
      clearSearchArchiveEvent() { //组织档案清除
        this.searchWordArchive = ''
        this.getOriginalArchiveTableData()
      },
      handlePageArchive() { //组织档案分页相同方法
        if (this.archivesSeachStyle == 'N') {
          this.getArchiveTableData()
        } else {
          this.archivesSearch()
        }
      },
      handleSizeArchiveChange(val) { //组织档案切换当前条数
        this.pageArchiveSize = val
        this.handlePageArchive()
      },
      handleCurrentArchiveChange(val) { //组织档案切换当前页数
        this.currentArchivePage = val
        this.handlePageArchive()
      },
      handleArchiveSure() { //组织档案弹框确认
        this.formData = this.chooseArchive
        this.formData.parentOrgId = this.$route.params.data.treeId
        this.formData.orgName = this.$route.params.data.orgName
        this.archiveVisible = false
      },
      handleOrganizationSure() { //隶属机构弹框确认
        this.formData.parentOrgId = this.selectParentTreeId
        this.formData.orgName = this.selectParentOrgName
        this.organizationVisible = false
      },
      combineDatas() { //所传参数实体
        this.archivesDatas = {
          creditCode: this.formData.creditCode,
          name: this.formData.name,
          orgType: this.formData.orgType,
          type: this.formData.type,
          regStatus: this.formData.regStatus,
          actualCapital: this.formData.actualCapital,
          actualCapitalCurrency: this.formData.actualCapitalCurrency,
          alias: this.formData.alias,
          approvedTime: this.formData.approvedTime,
          base: this.formData.base,
          bizCat: this.formData.bizCat,
          bondName: this.formData.bondName,
          bondNum: this.formData.bondNum,
          bondType: this.formData.bondType,
          businessScope: this.formData.businessScope,
          cancelDate: this.formData.cancelDate,
          cancelReason: this.formData.cancelReason,
          companyOrgType: this.formData.companyOrgType,
          email: this.formData.email,
          estiblishTime: this.formData.estiblishTime,
          fromTime: this.formData.fromTime,
          historyNames: this.formData.historyNames,
          id: this.formData.id,
          industry: this.formData.industry,
          isMicroEnt: this.formData.isMicroEnt,
          legalPersonId: this.formData.legalPersonId,
          legalPersonName: this.formData.legalPersonName,
          linkMan: this.formData.linkMan,
          lintel: this.formData.lintel,
          orgCat: this.formData.orgCat,
          orgCode: this.formData.orgCode, //组织档案编码
          orgId: this.formData.orgId, //组织档案Id
          percentileScore: this.formData.percentileScore,
          regCapital: this.formData.regCapital,
          regInstitute: this.formData.regInstitute,
          regLocation: this.formData.regLocation,
          regNumber: this.formData.regNumber,
          regcapitalCurrency: this.formData.regcapitalCurrency,
          revokeDate: this.formData.revokeDate,
          revokeReason: this.formData.revokeReason,
          socialStaffNum: this.formData.socialStaffNum,
          staffNumRange: this.formData.staffNumRange,
          tags: this.formData.tags,
          taxNumber: this.formData.taxNumber,
          toTime: this.formData.toTime,
          usedBondName: this.formData.usedBondName,
          webUrl: this.formData.webUrl,
          zipCode: this.formData.zipCode,
          zone: this.formData.zone,
          orgNumber: this.formData.orgNumber,
          property3: this.formData.property3,
        }
        this.treeDatas = {
          orgCode: this.formData.orgCode,
          erpOrgCode: this.formData.erpOrgCode,
          erpOrgName: this.formData.erpOrgName,
          orgDegree: this.formData.orgDegree,
          orgId: this.formData.orgId, //组织档案
          // orgLevel: this.formData.orgLevel,
          orgName: this.formData.name,
          parentOrgId: this.formData.parentOrgId,
          remark: this.formData.remark,
          sortNo: this.formData.sortNo,
          treeId: this.formData.treeId,
        }
      },
      archivesSave(formName) { //保存
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.combineDatas()
            let data = {
              archives: this.archivesDatas,
              tree: this.treeDatas
            }
            addOrEdit(data).then(res => {
              if (res.data.code == 10000) {
                Message({
                  type: 'success',
                  message: '保存成功！'
                })
                this.$router.go(-1)
              }
            })
          }
        })
      },
      archivesEvt() { //关闭
        this.$router.go(-1)
      },
    }
  }
</script>
<style lang="scss">
  .basic-info {
    font-size: 14px;
    line-height: 32px;
    color: #303133;
    font-weight: 700
  }

  .code-first-row {
    margin-bottom: 6px;
  }

  .line-style {
    width: 2px;
    height: 8px;
    background: #409EFF;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
  }

  .input-width {
    width: 100%;
  }

  .visible-input {
    display: none;
  }

  .outer-style {
    padding: 10px 20px;
  }

  .textarea-inner-style {
    .el-form-item__content {
      flex: 1;
      .el-date-editor{
        width: 100%
      }
    }
  }

  .inner-inputs-style {
    display: flex !important;
  }
</style>
